package com.situ.hospital.service.impl;

import com.situ.hospital.dao.IPatientDAO;
import com.situ.hospital.dao.Impl.PatientDAOImpl;
import com.situ.hospital.pojo.Patient;
import com.situ.hospital.pojo.query.PatientQuery;
import com.situ.hospital.service.IPatientService;
import com.situ.hospital.util.PageResult;

import java.util.List;

public class PatientServiceImpl implements IPatientService {

    private IPatientDAO patientDAO = new PatientDAOImpl();

    @Override
    public PageResult<Patient> selectByPage(PatientQuery patientQuery) {
        List<Patient> list = patientDAO.selectByPage(patientQuery);
        int totalCount = patientDAO.selectTotalCount(patientQuery);
        return new PageResult<>(0, "", totalCount, list);
    }

    @Override
    public void deleteById(int id) {
        patientDAO.deleteById(id);
    }

    @Override
    public void deleteAll(String[] ids) {
        for(String id : ids) {
            patientDAO.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public void add(Patient patient) {
        patientDAO.add(patient);
    }

    @Override
    public Patient selectById(int id) {
        return patientDAO.selectById(id);
    }

    @Override
    public void update(Patient patient) {
        patientDAO.update(patient);
    }

    @Override
    public List<Patient> selectAll() {
        return patientDAO.selectAll();
    }
}
